home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F19098_EmpAttrTextBoxPull1.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2001-10-04  |  2.7 KB  |  68 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- ===========================================================
  3.   Category:       HTML
  4.   Sub-category:   TextBox
  5.   Author:         David Silverlight
  6.                   HeadGeek@xmlpitstop.com
  7.   Created:        2001-05-16
  8.   Description:-
  9.     This series of textboxes is generated using the pull method
  10.     of extracting xml attributes.   Each element will generate
  11.     a text box and the attributes will allow us to format the
  12.     text box according to the attribute values.  Also note that
  13.     we are using the Pull method to extract data from our xml
  14.     document.  The pull method is an approach where the use of
  15.     templates is minimized and data is accessed by 'pulling' it
  16.     from our xml document.
  17. ================================================================ -->
  18. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  19.   <xsl:output method="html" />
  20.   <xsl:template match="/">
  21.     <html>
  22.       <head>
  23.         <style type="text/css">
  24.         H1 {COLOR: red; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
  25.         H2 {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  26.         .head {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
  27.         .subhead {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  28.         .text {COLOR: black; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  29.         TH {COLOR: white; FONT-FAMILY: Arial; background-color: darkblue;}
  30.         TD {COLOR: darkblue; FONT-FAMILY: Arial}
  31.         TR { background-color: beige; }
  32.         BODY { background-color: beige; }
  33.         </style>
  34.       </head>
  35.       <body>
  36.         <h1>Generating a text box from xml (pull method)</h1>
  37.  
  38.         <xsl:for-each select="/employees/employee">
  39.           <!-- The following for-each loop will iterate through all of the child elements
  40.              of employee -->
  41.           <xsl:for-each select="*">
  42.             <xsl:value-of select="@desc" />
  43.  
  44.             <!-- Note: Curly braces are a shorthand for the value of an attribute -->
  45.             <xsl:element name="{@type}">
  46.               <!-- Set the Size of the textbox -->
  47.               <xsl:attribute name="size">
  48.                 <xsl:value-of select="@size" />
  49.               </xsl:attribute>
  50.  
  51.               <!-- Set the Size of the textbox -->
  52.               <xsl:attribute name="maxlength">
  53.                 <xsl:value-of select="@size" />
  54.               </xsl:attribute>
  55.  
  56.                <!-- Set the value of the text box -->
  57.               <xsl:attribute name="value">
  58.                 <xsl:value-of select="text()" />
  59.               </xsl:attribute>
  60.  
  61.               <br />
  62.             </xsl:element>
  63.           </xsl:for-each>
  64.         </xsl:for-each>
  65.       </body>
  66.     </html>
  67.   </xsl:template>
  68. </xsl:stylesheet>